'''
类和对象：

'''


class Person:
    """人类"""

    def __init__(self, name, age, gender, h):
        self.name = name
        self.age = age
        self.gender = gender
        self.h = h

    def eat(self, food='肉'):
        print('吃饭', food)

    def sleep(self, hour):
        self.eat()
        print('睡觉%s小时' % hour)

    def play(self):
        print('玩')

    def work(self):
        print('work')


p1 = Person('1', '20', 1, 165)
p2 = Person('2', '18', 0, 165)
p1.sleep(8)
print(p1.h)

print('--------------------------------')


# 声明狗类，属性：品种、名字、颜色、年龄、性别，功能：吃（xxx吃xxx）
class Dog:
    def __init__(self, name, kind, color, age, gender):
        self.name = name
        self.age = age
        self.kind = kind
        self.color = color
        self.gender = gender

    def eat(self, food):
        print('{}吃{}'.format(self.name, food))


D1 = Dog('大黄', '贵宾犬', '黄色', 2, '公')
D1.eat('肉')
